package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.PayPlanSheetUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/25 10:18
 * @since v1.0
 */
public interface PayPlanSheetUserModel extends IModel<PayPlanSheetUserEntity> {
    
    @Override
    List<PayPlanSheetUserEntity> findEntitys(Map<String, Object> param);

    /**
     * 保存实体
     *
     * @param PayPlanUserEntity 付款协同人团队实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @author feng.zheng
     * @date 2019/2/14 16:42
     */
    Integer save(PayPlanSheetUserEntity PayPlanUserEntity) throws XbbException;

    /**
     * 获取单个实体
     *
     * @param key    id主键
     * @param corpid 公司id
     * @return com.xbongbong.saas.domain.entity.PayPlanSheetUserEntity
     * @author feng.zheng
     * @date 2019/2/14 16:43
     */
    PayPlanSheetUserEntity getByKey(Long key, String corpid);

    /**
     * 不去重获取所有的对应ContractUser(构造方法引起了findEntitys中当不需要获取所有字段的时候去重不符合要求)
     *
     * @param param 参数
     * @return 创建时间： 2018年1月4日 下午3:37:40
     * 修改时间： 2018年1月4日 下午3:37:40 梁鲁江
     * @author 梁鲁江
     */
    List<PayPlanSheetUserEntity> findAllEntitys(Map<String, Object> param);



    /**
     * 批量解散团队依据供应商id
     * @param corpid
     * @param supplierIdList
     */
    void disbandedTeamByCustomerId(String corpid, List<Long> supplierIdList) throws XbbException;

    /**
     * 删除合同团队
     * @param contractUser
     */
    void delete(PayPlanSheetUserEntity contractUser) throws XbbException;

    /**
     * 查询协同团队基础列表
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String, Object> map);

    /**
     * 批量删除
     * @author 吴峰
     * @date 2019/3/13 16:20
     * @param purchaseIdIn 合同id
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer deleteByPurchaseIdIn(List<Long> purchaseIdIn, String corpid) throws XbbException;
    /**
     * 获取协同团队的业务数据
     * @param corpid 公司id
     * @param isMain 负责或协同
     * @param userId 用户id
     * @return List<Long>
     * @author long.rao
     * @date 2019-03-20 15:34
     */
    List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId);
    
    
    void insertBatch(List<PayPlanSheetUserEntity> payPlanSheetUserEntityList) throws XbbException;

    void insertBatch(List<PayPlanSheetUserEntity> payPlanSheetUserEntityList, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void insertBatch(List<PayPlanSheetUserEntity> payPlanSheetUserEntityList, boolean needThrow) throws XbbException;
    
    /**
     * 批量剔除团队
     * @param corpid
     * @param removeList 汇款团队
     */
    void batchDelete(String corpid, List<PayPlanSheetUserEntity> removeList,boolean needThrow) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del,boolean needThrow) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param payPlanSheetUserEntity
     */
    void updateEditFormPer(PayPlanSheetUserEntity payPlanSheetUserEntity) throws XbbException;

    /**
     * 编辑标签
     *
     * @param payPlanSheetUserEntity
     */
    void editLabel(PayPlanSheetUserEntity payPlanSheetUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     *
     *
     * @param corpid
     * @param paySheetId
     * @param isMain
     * @return
     */
    List<PayPlanSheetUserEntity> getPaySheetUserIdList(String corpid, Long paySheetId, Integer isMain);

    /**
     * 更新付款单团队删除标识
     *
     * @param corpid
     * @param payPlanSheetUserEntities
     * @param del
     */
    void deleteBatchUser(String corpid, List<PayPlanSheetUserEntity> payPlanSheetUserEntities, Integer del) throws XbbException;
}
